import 'package:dio/dio.dart';
import 'package:lcapp/api/request/api_client.dart';
import 'package:lcapp/api/request/response_data.dart';

class ZiXunAPI {

  static Future<ResponseData> getZiXunTypes() async {
    ResponseData responseData = await ApiClient.get("/api/articleType/articleTypes",);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getZiXunList(int page,int size,{int? articleTypeId,String? keyword, int vipFlag=0}) async {
    Map<String,dynamic> data = {
      'page':page,
      'size':size,
      'vipFlag':vipFlag
    };
    if(keyword!=null){
      data['keyword'] = keyword;
    }
    if(articleTypeId!=0){
      data['articleTypeId'] = articleTypeId;
    }
    if(articleTypeId!=0){
      data['articleTypeId'] = articleTypeId;
    }
    ResponseData responseData = await ApiClient.post("/api/article/findlist",data: data);
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> getZiXunDetail(int articleId) async {
    ResponseData responseData = await ApiClient.get("/api/article/loadArticle/$articleId");
    return ResponseData.createFrom(responseData, responseData.data);
  }

  static Future<ResponseData> ziXunCollection(int articleId,int operation) async {
    ResponseData responseData = await ApiClient.post("/api/article/collect",data: {
      'articleId':articleId,'operation':operation
    });
    return ResponseData.createFrom(responseData, responseData.data);
  }

}